package com.hjm.project.statistical.standard.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.statistical.standard.domain.AgentMonthStandard;
import com.hjm.project.statistical.standard.service.IAgentMonthStandardService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 达标台均Controller
 * 
 * @author maker-platform
 * @date 2021-06-23
 */
@Controller
@RequestMapping("/AgentMonthStandard/standard")
public class AgentMonthStandardController extends BaseController
{
    private String prefix = "statistical/AgentMonthStandard/standard";

    @Resource
    private IAgentMonthStandardService agentMonthStandardService;

    @RequiresPermissions("AgentMonthStandard:standard:view")
    @GetMapping()
    public String standard()
    {
        return prefix + "/standard";
    }

    /**
     * 查询达标台均列表
     */
    @RequiresPermissions("AgentMonthStandard:standard:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentMonthStandard agentMonthStandard)
    {
        startPage();
        List<AgentMonthStandard> list = agentMonthStandardService.selectAgentMonthStandardList(agentMonthStandard);
        return getDataTable(list);
    }

    /**
     * 导出达标台均列表
     */
    @RequiresPermissions("AgentMonthStandard:standard:export")
    @Log(title = "达标台均", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentMonthStandard agentMonthStandard)
    {
        List<AgentMonthStandard> list = agentMonthStandardService.selectAgentMonthStandardList(agentMonthStandard);
        ExcelUtil<AgentMonthStandard> util = new ExcelUtil<AgentMonthStandard>(AgentMonthStandard.class);
        return util.exportExcel(list, "达标台均");
    }

    /**
     * 新增达标台均
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存达标台均
     */
    @RequiresPermissions("AgentMonthStandard:standard:add")
    @Log(title = "达标台均", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentMonthStandard agentMonthStandard)
    {
        return toAjax(agentMonthStandardService.insertAgentMonthStandard(agentMonthStandard));
    }

    /**
     * 修改达标台均
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        AgentMonthStandard agentMonthStandard = agentMonthStandardService.selectAgentMonthStandardById(id);
        mmap.put("agentMonthStandard", agentMonthStandard);
        return prefix + "/edit";
    }

    /**
     * 修改保存达标台均
     */
    @RequiresPermissions("AgentMonthStandard:standard:edit")
    @Log(title = "达标台均", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentMonthStandard agentMonthStandard)
    {
        return toAjax(agentMonthStandardService.updateAgentMonthStandard(agentMonthStandard));
    }

    /**
     * 删除达标台均
     */
    @RequiresPermissions("AgentMonthStandard:standard:remove")
    @Log(title = "达标台均", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(agentMonthStandardService.deleteAgentMonthStandardByIds(ids));
    }
}
